package com.tpc.control.jpa;

import java.util.List;
import java.util.logging.Level;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 * A data access object (DAO) providing persistence and search support for
 * RoutingData entities. Transaction control of the save(), update() and
 * delete() operations must be handled externally by senders of these methods or
 * must be manually added to each of these methods for data to be persisted to
 * the JPA datastore.
 * 
 * @see com.tpc.control.jpa.RoutingData
 * @author MyEclipse Persistence Tools
 */

public class RoutingDataDAO implements IRoutingDataDAO {
	// property constants
	public static final String PROCESS01 = "process01";
	public static final String PROCESS02 = "process02";
	public static final String PROCESS03 = "process03";
	public static final String PROCESS04 = "process04";
	public static final String PROCESS05 = "process05";
	public static final String PROCESS06 = "process06";
	public static final String PROCESS07 = "process07";
	public static final String PROCESS08 = "process08";
	public static final String PROCESS09 = "process09";
	public static final String PROCESS10 = "process10";
	public static final String PROCESS11 = "process11";
	public static final String PROCESS12 = "process12";
	public static final String PROCESS13 = "process13";
	public static final String PROCESS14 = "process14";
	public static final String PROCESS15 = "process15";
	public static final String PROCESS16 = "process16";
	public static final String PROCESS17 = "process17";
	public static final String PROCESS18 = "process18";
	public static final String PROCESS19 = "process19";
	public static final String PROCESS20 = "process20";
	public static final String PROCESS_NAME01 = "processName01";
	public static final String PROCESS_NAME02 = "processName02";
	public static final String PROCESS_NAME03 = "processName03";
	public static final String PROCESS_NAME04 = "processName04";
	public static final String PROCESS_NAME05 = "processName05";
	public static final String PROCESS_NAME06 = "processName06";
	public static final String PROCESS_NAME07 = "processName07";
	public static final String PROCESS_NAME08 = "processName08";
	public static final String PROCESS_NAME09 = "processName09";
	public static final String PROCESS_NAME10 = "processName10";
	public static final String PROCESS_NAME11 = "processName11";
	public static final String PROCESS_NAME12 = "processName12";
	public static final String PROCESS_NAME13 = "processName13";
	public static final String PROCESS_NAME14 = "processName14";
	public static final String PROCESS_NAME15 = "processName15";
	public static final String PROCESS_NAME16 = "processName16";
	public static final String PROCESS_NAME17 = "processName17";
	public static final String PROCESS_NAME18 = "processName18";
	public static final String PROCESS_NAME19 = "processName19";
	public static final String PROCESS_NAME20 = "processName20";

	private EntityManager getEntityManager() {
		return EntityManagerHelper.getEntityManager();
	}

	/**
	 * Perform an initial save of a previously unsaved RoutingData entity. All
	 * subsequent persist actions of this entity should use the #update()
	 * method. This operation must be performed within the a database
	 * transaction context for the entity's data to be permanently saved to the
	 * persistence store, i.e., database. This method uses the
	 * {@link javax.persistence.EntityManager#persist(Object)
	 * EntityManager#persist} operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * RoutingDataDAO.save(entity);
	 * EntityManagerHelper.commit();
	 * </pre>
	 * 
	 * @param entity
	 *            RoutingData entity to persist
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void save(RoutingData entity) {
		EntityManagerHelper
				.log("saving RoutingData instance", Level.INFO, null);
		try {
			getEntityManager().persist(entity);
			EntityManagerHelper.log("save successful", Level.INFO, null);
		} catch (RuntimeException re) {
			EntityManagerHelper.log("save failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Delete a persistent RoutingData entity. This operation must be performed
	 * within the a database transaction context for the entity's data to be
	 * permanently deleted from the persistence store, i.e., database. This
	 * method uses the {@link javax.persistence.EntityManager#remove(Object)
	 * EntityManager#delete} operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * RoutingDataDAO.delete(entity);
	 * EntityManagerHelper.commit();
	 * entity = null;
	 * </pre>
	 * 
	 * @param entity
	 *            RoutingData entity to delete
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void delete(RoutingData entity) {
		EntityManagerHelper.log("deleting RoutingData instance", Level.INFO,
				null);
		try {
			entity = getEntityManager().getReference(RoutingData.class,
					entity.getId());
			getEntityManager().remove(entity);
			EntityManagerHelper.log("delete successful", Level.INFO, null);
		} catch (RuntimeException re) {
			EntityManagerHelper.log("delete failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Persist a previously saved RoutingData entity and return it or a copy of
	 * it to the sender. A copy of the RoutingData entity parameter is returned
	 * when the JPA persistence mechanism has not previously been tracking the
	 * updated entity. This operation must be performed within the a database
	 * transaction context for the entity's data to be permanently saved to the
	 * persistence store, i.e., database. This method uses the
	 * {@link javax.persistence.EntityManager#merge(Object) EntityManager#merge}
	 * operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * entity = RoutingDataDAO.update(entity);
	 * EntityManagerHelper.commit();
	 * </pre>
	 * 
	 * @param entity
	 *            RoutingData entity to update
	 * @return RoutingData the persisted RoutingData entity instance, may not be
	 *         the same
	 * @throws RuntimeException
	 *             if the operation fails
	 */
	public RoutingData update(RoutingData entity) {
		EntityManagerHelper.log("updating RoutingData instance", Level.INFO,
				null);
		try {
			RoutingData result = getEntityManager().merge(entity);
			EntityManagerHelper.log("update successful", Level.INFO, null);
			return result;
		} catch (RuntimeException re) {
			EntityManagerHelper.log("update failed", Level.SEVERE, re);
			throw re;
		}
	}

	public RoutingData findById(RoutingDataId id) {
		EntityManagerHelper.log("finding RoutingData instance with id: " + id,
				Level.INFO, null);
		try {
			RoutingData instance = getEntityManager().find(RoutingData.class,
					id);
			return instance;
		} catch (RuntimeException re) {
			EntityManagerHelper.log("find failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Find all RoutingData entities with a specific property value.
	 * 
	 * @param propertyName
	 *            the name of the RoutingData property to query
	 * @param value
	 *            the property value to match
	 * @return List<RoutingData> found by query
	 */
	@SuppressWarnings("unchecked")
	public List<RoutingData> findByProperty(String propertyName,
			final Object value) {
		EntityManagerHelper.log("finding RoutingData instance with property: "
				+ propertyName + ", value: " + value, Level.INFO, null);
		try {
			final String queryString = "select model from RoutingData model where model."
					+ propertyName + "= :propertyValue";
			Query query = getEntityManager().createQuery(queryString);
			query.setParameter("propertyValue", value);
			return query.getResultList();
		} catch (RuntimeException re) {
			EntityManagerHelper.log("find by property name failed",
					Level.SEVERE, re);
			throw re;
		}
	}

	public List<RoutingData> findByProcess01(Object process01) {
		return findByProperty(PROCESS01, process01);
	}

	public List<RoutingData> findByProcess02(Object process02) {
		return findByProperty(PROCESS02, process02);
	}

	public List<RoutingData> findByProcess03(Object process03) {
		return findByProperty(PROCESS03, process03);
	}

	public List<RoutingData> findByProcess04(Object process04) {
		return findByProperty(PROCESS04, process04);
	}

	public List<RoutingData> findByProcess05(Object process05) {
		return findByProperty(PROCESS05, process05);
	}

	public List<RoutingData> findByProcess06(Object process06) {
		return findByProperty(PROCESS06, process06);
	}

	public List<RoutingData> findByProcess07(Object process07) {
		return findByProperty(PROCESS07, process07);
	}

	public List<RoutingData> findByProcess08(Object process08) {
		return findByProperty(PROCESS08, process08);
	}

	public List<RoutingData> findByProcess09(Object process09) {
		return findByProperty(PROCESS09, process09);
	}

	public List<RoutingData> findByProcess10(Object process10) {
		return findByProperty(PROCESS10, process10);
	}

	public List<RoutingData> findByProcess11(Object process11) {
		return findByProperty(PROCESS11, process11);
	}

	public List<RoutingData> findByProcess12(Object process12) {
		return findByProperty(PROCESS12, process12);
	}

	public List<RoutingData> findByProcess13(Object process13) {
		return findByProperty(PROCESS13, process13);
	}

	public List<RoutingData> findByProcess14(Object process14) {
		return findByProperty(PROCESS14, process14);
	}

	public List<RoutingData> findByProcess15(Object process15) {
		return findByProperty(PROCESS15, process15);
	}

	public List<RoutingData> findByProcess16(Object process16) {
		return findByProperty(PROCESS16, process16);
	}

	public List<RoutingData> findByProcess17(Object process17) {
		return findByProperty(PROCESS17, process17);
	}

	public List<RoutingData> findByProcess18(Object process18) {
		return findByProperty(PROCESS18, process18);
	}

	public List<RoutingData> findByProcess19(Object process19) {
		return findByProperty(PROCESS19, process19);
	}

	public List<RoutingData> findByProcess20(Object process20) {
		return findByProperty(PROCESS20, process20);
	}

	public List<RoutingData> findByProcessName01(Object processName01) {
		return findByProperty(PROCESS_NAME01, processName01);
	}

	public List<RoutingData> findByProcessName02(Object processName02) {
		return findByProperty(PROCESS_NAME02, processName02);
	}

	public List<RoutingData> findByProcessName03(Object processName03) {
		return findByProperty(PROCESS_NAME03, processName03);
	}

	public List<RoutingData> findByProcessName04(Object processName04) {
		return findByProperty(PROCESS_NAME04, processName04);
	}

	public List<RoutingData> findByProcessName05(Object processName05) {
		return findByProperty(PROCESS_NAME05, processName05);
	}

	public List<RoutingData> findByProcessName06(Object processName06) {
		return findByProperty(PROCESS_NAME06, processName06);
	}

	public List<RoutingData> findByProcessName07(Object processName07) {
		return findByProperty(PROCESS_NAME07, processName07);
	}

	public List<RoutingData> findByProcessName08(Object processName08) {
		return findByProperty(PROCESS_NAME08, processName08);
	}

	public List<RoutingData> findByProcessName09(Object processName09) {
		return findByProperty(PROCESS_NAME09, processName09);
	}

	public List<RoutingData> findByProcessName10(Object processName10) {
		return findByProperty(PROCESS_NAME10, processName10);
	}

	public List<RoutingData> findByProcessName11(Object processName11) {
		return findByProperty(PROCESS_NAME11, processName11);
	}

	public List<RoutingData> findByProcessName12(Object processName12) {
		return findByProperty(PROCESS_NAME12, processName12);
	}

	public List<RoutingData> findByProcessName13(Object processName13) {
		return findByProperty(PROCESS_NAME13, processName13);
	}

	public List<RoutingData> findByProcessName14(Object processName14) {
		return findByProperty(PROCESS_NAME14, processName14);
	}

	public List<RoutingData> findByProcessName15(Object processName15) {
		return findByProperty(PROCESS_NAME15, processName15);
	}

	public List<RoutingData> findByProcessName16(Object processName16) {
		return findByProperty(PROCESS_NAME16, processName16);
	}

	public List<RoutingData> findByProcessName17(Object processName17) {
		return findByProperty(PROCESS_NAME17, processName17);
	}

	public List<RoutingData> findByProcessName18(Object processName18) {
		return findByProperty(PROCESS_NAME18, processName18);
	}

	public List<RoutingData> findByProcessName19(Object processName19) {
		return findByProperty(PROCESS_NAME19, processName19);
	}

	public List<RoutingData> findByProcessName20(Object processName20) {
		return findByProperty(PROCESS_NAME20, processName20);
	}

	/**
	 * Find all RoutingData entities.
	 * 
	 * @return List<RoutingData> all RoutingData entities
	 */
	@SuppressWarnings("unchecked")
	public List<RoutingData> findAll() {
		EntityManagerHelper.log("finding all RoutingData instances",
				Level.INFO, null);
		try {
			final String queryString = "select model from RoutingData model";
			Query query = getEntityManager().createQuery(queryString);
			return query.getResultList();
		} catch (RuntimeException re) {
			EntityManagerHelper.log("find all failed", Level.SEVERE, re);
			throw re;
		}
	}

}